﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class VoyageMaster
    {
        public string vessel_name = string.Empty;
        public string dept_fullname = string.Empty;
        public string profit_centre_fullname = string.Empty;
        public int voyage_no =0;
        public string charterer = string.Empty;
        public string head_fixture_type = string.Empty;
        public DateTime cp_date = new DateTime(1900, 1, 1);
        public DateTime estimated_start_date = new DateTime(1900, 1, 1);
        public DateTime start_ballast_date = new DateTime(1900, 1, 1);
        public DateTime start_voyage_delivery_date = new DateTime(1900, 1, 1);
        public DateTime end_voyage_delivery_date = new DateTime(1900, 1, 1);
        public decimal days_total_on_hire = 0;
        public decimal days_total_off_hire = 0;
        public decimal tce = 0;
        public string commodity_type = string.Empty;
        public decimal cargo_quantity = 0;
        public string charterer_ = "";
        public string status = string.Empty;
        public int head_fixture_number = 0;
        public string fixture_ref = string.Empty;
        public string head_fixture_ref = string.Empty;
        public string freight_rate_basis = string.Empty;
        public string operator_m = string.Empty;
        public string admin = string.Empty;
        public string voyage_ref = string.Empty;
        public DateTime created_date = new DateTime(1900, 1, 1);
        public decimal Rate = 0;
        public string commodity= string.Empty;
        public string remarks = string.Empty;
        public DateTime last_updated_date = new DateTime(1900, 1, 1);


        public int i_voyage_master_id = 0;
        public string pickup_flag = string.Empty;
        public string pickup_remark = string.Empty;
        public string vessel_code = string.Empty;
        public DateTime pickup_date = new DateTime(1900, 1, 1);
        public DateTime pickup_update_date = new DateTime(1900, 1, 1);
        public DateTime insert_date = new DateTime(1900, 1, 1);
        
        public VoyageMaster(SqlDataReader rd, bool isfrominterface)
        {
            vessel_name = rd["vessel_name"] is DBNull ? vessel_name : rd["vessel_name"].ToString();
            dept_fullname = rd["dept_fullname"] is DBNull ? dept_fullname : rd["dept_fullname"].ToString();
            profit_centre_fullname = rd["profit_centre_fullname"] is DBNull ? profit_centre_fullname : rd["profit_centre_fullname"].ToString();
            voyage_no = rd["voyage_no"] is DBNull ? voyage_no : Convert.ToInt32(rd["voyage_no"]);
            charterer = rd["charterer"] is DBNull ? charterer : rd["charterer"].ToString();
            head_fixture_type = rd["head_fixture_type"] is DBNull ? head_fixture_type : rd["head_fixture_type"].ToString();
            cp_date = rd["cp_date"] is DBNull ? cp_date : Convert.ToDateTime(rd["cp_date"]);
            estimated_start_date = rd["estimated_start_date"] is DBNull ? estimated_start_date : Convert.ToDateTime(rd["estimated_start_date"]);
            start_ballast_date = rd["start_ballast_date"] is DBNull ? start_ballast_date : Convert.ToDateTime(rd["start_ballast_date"]);
            start_voyage_delivery_date = rd["start_voyage_delivery_date"] is DBNull ? start_voyage_delivery_date : Convert.ToDateTime(rd["start_voyage_delivery_date"]);
            end_voyage_delivery_date = rd["end_voyage_delivery_date"] is DBNull ? end_voyage_delivery_date : Convert.ToDateTime(rd["end_voyage_delivery_date"]);
            days_total_on_hire = rd["days_total_on_hire"] is DBNull ? days_total_on_hire : Convert.ToDecimal(rd["days_total_on_hire"]);
            days_total_off_hire = rd["days_total_off_hire"] is DBNull ? days_total_off_hire : Convert.ToDecimal(rd["days_total_off_hire"]);
            tce = rd["tce"] is DBNull ? tce : Convert.ToInt32(rd["tce"]);
            commodity_type = rd["commodity_type"] is DBNull ? commodity_type : rd["commodity_type"].ToString();
            cargo_quantity = rd["cargo_quantity"] is DBNull ? cargo_quantity : Convert.ToDecimal(rd["cargo_quantity"]);
            status = rd["status"] is DBNull ? status : rd["status"].ToString();
            head_fixture_number = rd["head_fixture_number"] is DBNull ? head_fixture_number : Convert.ToInt32(rd["head_fixture_number"]);
            fixture_ref = rd["fixture_ref"] is DBNull ? fixture_ref : rd["fixture_ref"].ToString();
            head_fixture_ref = rd["head_fixture_ref"] is DBNull ? head_fixture_ref : rd["head_fixture_ref"].ToString();
            freight_rate_basis = rd["freight_rate_basis"] is DBNull ? freight_rate_basis : rd["freight_rate_basis"].ToString();
            operator_m = rd["operator_m"] is DBNull ? operator_m : rd["operator_m"].ToString();
            admin = rd["admin"] is DBNull ? admin : rd["admin"].ToString();
            voyage_ref = rd["voyage_ref"] is DBNull ? voyage_ref : rd["voyage_ref"].ToString();
            created_date = rd["created_date"] is DBNull ? created_date : Convert.ToDateTime(rd["created_date"]);
            Rate = rd["Rate"] is DBNull ? Rate : Convert.ToDecimal(rd["Rate"]);
            commodity = rd["commodity"] is DBNull ? commodity : rd["commodity"].ToString();
            last_updated_date = rd["last_updated_date"] is DBNull ? last_updated_date : Convert.ToDateTime(rd["last_updated_date"]);
            charterer_ = rd["charterer_"] is DBNull ? charterer_ : rd["charterer_"].ToString();
            vessel_code = rd["vessel_code"] is DBNull ? "" : rd["vessel_code"].ToString();
            if (isfrominterface)
            {
                pickup_flag = rd["pickup_flag"] is DBNull ? "" : rd["pickup_flag"].ToString();
                pickup_remark = rd["pickup_flag"] is DBNull ? "" : rd["pickup_flag"].ToString();
                pickup_date = rd["pickup_date"] is DBNull ? new DateTime(1900, 1, 1) : Convert.ToDateTime(rd["pickup_date"]);
                pickup_update_date = rd["pickup_update_date"] is DBNull ? new DateTime(1900, 1, 1) : Convert.ToDateTime(rd["pickup_update_date"]);
                insert_date = rd["insert_date"] is DBNull ? new DateTime(1900, 1, 1) : Convert.ToDateTime(rd["insert_date"]);
                i_voyage_master_id = rd["i_voyage_master_id"] is DBNull ? 0 : Convert.ToInt32(rd["i_voyage_master_id"]);
                remarks = rd["remarks"] is DBNull ? "" : rd["remarks"].ToString();

            }
        }
        public VoyageMaster(SqlDataReader rd)
        {
            vessel_name = rd["vessel_name"] is DBNull ? vessel_name : rd["vessel_name"].ToString();
            voyage_no = rd["voyage_no"] is DBNull ? voyage_no : Convert.ToInt32(rd["voyage_no"]);
            created_date = rd["created_date"] is DBNull ? created_date : Convert.ToDateTime(rd["created_date"]);
            remarks = rd["remarks"] is DBNull ? "" : rd["remarks"].ToString();
            pickup_date = rd["pickup_date"] is DBNull ? new DateTime(1900, 1, 1) : Convert.ToDateTime(rd["pickup_date"]);
        }
    }
}
